package com.example.day2.live.view;

import android.annotation.SuppressLint;
import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import androidx.annotation.Nullable;

import com.bumptech.glide.Glide;
import com.example.day2.R;
import com.example.day2.entity.GiftResult;

/**
 * 自定义布局
 */
public class GiftLayout extends LinearLayout {
    private ImageView iv1,iv2;
    private TextView tv1,tv2,tv3;
    @SuppressLint("MissingInflatedId")
    public GiftLayout(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
        //加载布局文件
        View inflate = LayoutInflater.from(getContext()).inflate(R.layout.gift_layout, null);
        iv1 = inflate.findViewById(R.id.iv_1);
        iv2 = inflate.findViewById(R.id.iv_2);
        tv1 = inflate.findViewById(R.id.tv);
        tv2 = inflate.findViewById(R.id.tv2);
        tv3 = inflate.findViewById(R.id.tv3);
        addView(inflate);
    }

    public void setUserImg(String url){
        Glide.with(getContext()).load(url).circleCrop().into(iv1);

    }
    public void setUserName(String userName){
      tv1.setText(userName+"");
    }
    public void setCount(int  count){
        tv3.setText("X"+count);
    }
    public void setGift(GiftResult.DataBean dataBean){
        tv2.setText(dataBean.getGiftname());
        Glide.with(getContext()).load(dataBean.getGiftpath()).into(iv2);
    }

}
